package edu.bw.resolver;

import edu.bw.utils.ResponseData;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;


@Component
@Log4j2(topic = "fileLogger")
public class ExceptionResolver implements HandlerExceptionResolver {
    /**
     * @param request
     * @param response
     * @param handler
     * @param e
     * @return
     */
    @Override
    public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
        System.out.println(handler);
        log.error(handler+":"+ex.getMessage(),ex);
        return new ModelAndView("error");
    }
}
